import sys
sys.path.append('..\\..')
from Djoser import *

import os

root = Tk()
f1 = Frame(root)
f1.pack()
currentFrame = f1

def newTestBtn(strName, fnCallback=None):
	btn = DjButton(currentFrame)
	btn.pack(side=LEFT)
	btn.text = strName
	if fnCallback: btn.onclick = fnCallback
	return btn

def callback(): print 'hi'
btn = DjButton(f1)
btn.pack()
btn.text = 'T&his' #Should underline the h. Pretty cool.
assert btn.text=='T&his'
btn.onclick = callback


def disable(): btn.enabled = not btn.enabled
btn2 = newTestBtn('Disable btn 1', disable)

def toggledefault(): btn25.defaultstyle = not btn25.defaultstyle
btn25 = newTestBtn('default', toggledefault)

def size(): btn3.height = btn3.width=10
btn3 = newTestBtn('Resize', size)

def borderstyle(): 
	btn4.borderstyle = 'sunken'
	assert btn4.borderstyle == 'sunken'
btn4 = newTestBtn('BorderStyle', borderstyle)

def borderwidth(): 
	btn5.borderwidth = 4
	assert str(btn5.borderwidth) == '4' #It is not a string or integer.
btn5 =newTestBtn('BorderWidth',borderwidth)

def fonttest():
	btn6.font = ('Times New Roman', 12, 'normal')
	print btn6.font
btn6 = newTestBtn('Font', fonttest)

def anchortest():
	btn7.alignment = 'right'
	assert btn7.alignment == 'right'
btn7 = newTestBtn('A test of how alignment will work and also line wrap', anchortest)
btn7.wrapwidth=50

def colorstest():
	btn.color = (0,0,255)
	btn.bgcolor = (255,255,255)
btn8 = newTestBtn('Color btn 1', colorstest)
btn8.activebgcolor = (0,0,100)
btn8.activecolor = (255,255,255)

f2 = Frame(root)
f2.pack()

img1 = PhotoImage(format='gif', data='R0lGODlhGAAYAIABAAAAAP///yH5BAEAAAEALAAAAAAYABgAAAI0jI+py+0PAXxATlbtTVlv03lbKE5kSZ3fWY0surxtRH5BduMuqF9eZzsAg7xZcEg0EpebAgA7')
img2 = PhotoImage(format='gif', data='R0lGODlhGAAYAJECAP///wAAAP///wAAACH5BAEAAAIALAAAAAAYABgAAAJOlI+pixEMGwAvwjCrXZhu1mmfRDkjGZpjmGXi1VLtezgPK+e0kE6+H+IAf8QMKFYEwjpJ47H529WgShhVSmpip9Att+j9EsMGm9l2OhUAADs=')
img3 = PhotoImage(format='gif', data='R0lGODlhGAAYAKIHAAAAAP////b29kpKSvX19bGxsUlJSf///yH5BAEAAAcALAAAAAAYABgAAAM+eLrc/jDKSau9D2jMgBkGwClAEAzieJRoymkA4b5FIMyXJgR4Xuy9iiYgU61qN5VGFhTCjKsNVDqFWq/YSwIAOw==')

btnTestIcon = DjButton(f2, text='Icon Test')
btnTestIcon.icon = img1
btnTestIcon.height = 50 #once an icon is set, these are in terms of pixels!
btnTestIcon.width = 100
btnTestIcon.pack()

f3 = Frame(root)
f3.pack()
currentFrame = f3

def icontest1(): btnTestIcon.icon = img2
btn9 = newTestBtn('Change icon', icontest1)

def icontest2(): btnTestIcon.icon = (img3, 'no_label')
btn10 = newTestBtn('No label', icontest2)

def icontest3():
	if btnTestIcon.icon[1]=='bottom': btnTestIcon.icon = (img3, 'top')
	else: btnTestIcon.icon = (img3, 'bottom')
btn11 = newTestBtn('above/below', icontest3)

def anchortest():
	btnTestIcon.anchor = 'e'
	assert btnTestIcon.anchor == 'e'
btn12 = newTestBtn('anchor', anchortest)

f1.mainloop()